package edu.hzit.data.service.impl;

import edu.hzit.data.entity.Expense;
import edu.hzit.data.mapper.ExpenseMapper;
import edu.hzit.data.service.ExpenseService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ExpenseServiceImpl implements ExpenseService {
    @Resource
    private ExpenseMapper expenseMapper;
    @Override
    public int insert(Expense expense) {
        return expenseMapper.insert(expense);
    }

    @Override
    public List<Expense> loadList() {
        return expenseMapper.loadList();
    }

    @Override
    public Expense selectById(int expenseId) {
        return expenseMapper.selectById(expenseId);
    }

    @Override
    public int delete(int expenseId) {
        return expenseMapper.delete(expenseId);
    }

    @Override
    public int update(Expense expense) {
        return expenseMapper.update(expense);
    }

    @Override
    public int sum(Expense expense) {
        if (expenseMapper.sum(expense) == null){
            return 0;
        }else {
            return expenseMapper.sum(expense);
        }
    }

//    @Override
//    public int sumByMonth(@Param("userId") int userId, @Param("month") int month) {
//        return expenseMapper.sumByMonth(userId,month);
//    }
}
